package holiday_demo.pc;

public class Computer {
    public void powerOn(){
        System.out.println("笔记本电脑开机！");
    }
    public void powerOff(){
        System.out.println("笔记本电脑关机！");
    }

    //使用USB设备的方法，利用USB接口来传参
    public void usbDevice(USB usb){
        usb.open();
        if(usb instanceof Mouse){
            Mouse mouse=(Mouse) usb;//向下转型
            mouse.cLick();
        }
        if (usb instanceof KeyBoard){
            KeyBoard keyBoard=(KeyBoard) usb;
            keyBoard.type();
        }
        usb.close();
    }
}
